#include "JDD/classes/Console.hpp"
#include <iostream>
namespace JDD
{
Console::Console(unsigned int theHeight, unsigned int theWidth)
{
    mLineNum=0;
    mHeight=theHeight;
	mWidth=theWidth;
}
Console::~Console()
{

}
void Console::NewLine(std::string theString)
{
	std::string anSubString="";
	unsigned int anCutTimes=0;
	if(theString.length()>mWidth)
	{
		for(anCutTimes=0; anCutTimes<theString.length()/mWidth+1;anCutTimes++)
		{
			anSubString=theString.substr(anCutTimes*mWidth, mWidth);
			mLine.push_back(anSubString);
			mLineNum++;
		}
	}
	else
	{
		mLine.push_back(theString);
		mLineNum++;
	}

}
void Console::Output()
{
    std::vector<std::string>::iterator anIter;
    for(anIter=mLine.begin(); anIter!=mLine.end(); ++anIter)
    {
        std::cout<< (*anIter) <<std::endl;
    }
}
std::string Console::GetLine(int theY)
{
    if(theY>=0 && (unsigned int)theY<mLine.size())
        return mLine[theY];
    else
        return "";
}
void Console::Clear()
{
    mLine.clear();
    mLineNum=0;
}
}
